"""
1.元素定位.py
导包:
    from selenium.webdriver.common.by import By
八种定位方式:
    ID = "id"
    XPATH = "xpath"
    LINK_TEXT = "link text"
    PARTIAL_LINK_TEXT = "partial link text"
    NAME = "name"
    TAG_NAME = "tag name"
    CLASS_NAME = "class name"
    CSS_SELECTOR = "css selector"
    1. by id:
    2. by name
"""
from selenium import webdriver
from time import  sleep
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
sleep(2)
driver.get("http://www.baidu.com")
sleep(5)
# driver.find_element(By.ID,"kw").send_keys("周慧敏")
# driver.find_element(By.NAME,"wd").send_keys("邱淑贞")
# driver.find_element(By.CLASS_NAME,"s_ipt").send_keys("关之琳")
# driver.find_element(By.TAG_NAME,"input").send_keys("李嘉欣") # 不推荐
# driver.find_element(By.XPATH,'//*[@id="kw"]').send_keys("李嘉欣")
# driver.find_element(By.CSS_SELECTOR,"#kw").send_keys("张曼玉")  # 推荐使用 css
# driver.find_element(By.LINK_TEXT,"新闻").click()
driver.find_element(By.PARTIAL_LINK_TEXT,"新").click()
sleep(2)

driver.find_element(By.ID,"su").click()
sleep(5)
driver.quit()